package com.example.demo.cotroller;

import com.example.demo.config.AjaxResult;
import com.example.demo.pojo.LoginUser;
import com.example.demo.pojo.SysMenu;
import com.example.demo.service.SysMenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api("菜单查询")
@RequestMapping
@RestController
public class SysMenuCotroller {
  @Autowired
  private SysMenuService sysMenuService;
  @ApiOperation("查询")
  @GetMapping("/menuList")
  public AjaxResult menuList(){
    LoginUser loginUser=(LoginUser)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    List<SysMenu> sysMenus = sysMenuService.list1(loginUser.getSysUser().getUserId().intValue());
    return AjaxResult.success(sysMenus);
  }
}
